using Microsoft.AspNetCore.Mvc;
using 后端服务.Services;

namespace 后端服务.Controllers;

[ApiController]
[Route("api/[controller]")]
public class SqlLogController : ControllerBase
{
    private readonly SqlLoggerService _loggerService;

    public SqlLogController(SqlLoggerService loggerService)
    {
        _loggerService = loggerService;
    }

    [HttpGet]
    public IActionResult GetLogs([FromQuery] int count = 20, [FromQuery] bool onlyErrors = false)
    {
        var logs = _loggerService.GetRecentQueries(count, onlyErrors);
        return Ok(logs);
    }
}